package io.renren.modules.jxgkphone.controller;


import io.renren.common.utils.R;
import io.renren.modules.jxgk.utils.UUidCreater;
import io.renren.modules.jxgkphone.entity.ElectiveCourse;
import io.renren.modules.jxgkphone.entity.EvaluationContent;
import io.renren.modules.jxgkphone.entity.TeachingEvaluation;
import io.renren.modules.jxgkphone.service.ElectiveCourseEvaluationService;
import io.renren.modules.jxgkphone.tempEntity.TempECEEntity;
import io.renren.modules.jxgkphone.tempEntity.TempTeachingEvaluation;
import io.renren.modules.sys.entity.SysUserEntity;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/electiveCourseEvaluation")
public class ElectiveCourseEvaluationController {

    @Autowired
    ElectiveCourseEvaluationService electiveCourseEvaluationService;

    @RequestMapping("/getElectiveCourseList")
    public R getElectiveCourseList() {
        //用户名
        String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
        List<ElectiveCourse> te=  electiveCourseEvaluationService.getElectiveCourseList(username);
//        List<TeachingEvaluation> te = teachingEvaluationService.findEvaluationInfo(tid,sid,cid);
//        List<EvaluationContent> ec=new ArrayList<>();
//        for(TeachingEvaluation tee:te){
//            String ecid=tee.getEvaluationContent();
//            EvaluationContent et=teachingEvaluationService.findEvaluationContentById(ecid);
//            ec.add(et);
//        }
        return R.ok().put("list", te);
    }
    @RequestMapping("/insertEvaluation")
    public R InsertTeachingEvaluation(@RequestBody TempTeachingEvaluation[] te) {
//@RequestBody TempECEEntity te

        List<TempTeachingEvaluation> list = Arrays.asList(te);
        electiveCourseEvaluationService.saveElectiveCoursEvaluation(te);
        return R.ok();

    }

}
